import 'package:flutter/material.dart';
import 'package:flutter_todo_2019/common/application.dart';
import 'package:flutter_todo_2019/common/common.dart';
import 'package:flutter_todo_2019/event/theme_change_event.dart';
import 'package:flutter_todo_2019/page/utils/sp_util.dart';
import 'package:flutter_todo_2019/res/colors.dart';

class ThemeUtils {
  /// 默认主题色
  static const Color defaultColor = Colours.app_nomal_color;

  /// 当前的主题色
  static Color currentThemeColor = defaultColor;

  /// 是否是夜间模式
  static bool dark = false;

  static ThemeData getThemeData() {
    if (dark) {
      return new ThemeData(
        brightness: Brightness.dark,
        primaryColor: Color(0xFF35464E),
        primaryColorDark: Color(0xFF212A2F),
        accentColor: Color(0xFF35464E),
        dividerColor: Color(0x1FFFFFFF),
      );
    } else {
      return new ThemeData(
        brightness: Brightness.light,
        primaryColor: currentThemeColor,
        primaryColorDark: currentThemeColor,
        accentColor: currentThemeColor,
        dividerColor: Color(0x1F000000),
      );
    }
  }
  static changeTheme(Color value){
    SPUtil.putString(Constants.THEME_COLOR_KEY, value.toString());
    ThemeUtils.currentThemeColor = value;
    Application.eventBus.fire(ThemeChangeEvent());
  }
}
